paddle

基本是工训备赛过程中,使用到Paddle框架的例子

Paddle安装

记得安装cuda,还有cudnn,以及版本要对应上

PaddleYOLO使用方法

训练自己的数据集 官方教程

数据集标注

  • 看清楚模型训练的数据集格式以及对应的配置文件
  • VOC或者是COCO格式等等
  • 准备

标注软件:labelimg

修改对应的配置文件

image-20231017195049381

配置文件 配置

相关文件

image-20231017194747641

启动命令

详细的命令参数去官网上看

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 训练
python tools/train.py -c configs/yolov3/yolov3_darknet53_270e_voc.yml --eval --use_vdl=true --vdl_log_dir=vdl_dir/garbage_tenth

# Paddle继续训练,加个参数 -r
python tools/train.py -c configs/yolov3/yolov3_darknet53_270e_voc.yml --eval --use_vdl=true --vdl_log_dir=vdl_dir/garbage_tenth -r D:/19693/Desktop/DeepLearning/PaddleYOLO/output/10_12/29.pdparams

# 推理
python tools/infer.py -c configs/yolov3/yolov3_darknet53_270e_voc.yml --infer_img="D:/19693/Desktop/grabage_data/grabage_4cls_3/images/img1.jpg" -o weights="D:/19693/Desktop/DeepLearning/PaddleYOLO/output/yolov3_darknet53_270e_voc/best_model.pdparams"

# 模型评估
python tools/eval.py -c configs/yolov3/yolov3_darknet53_270e_voc.yml -o weights="D:/19693/Desktop/DeepLearning/PaddleYOLO/output/100_yolov3_darknet53_270e_voc/model_final.pdparams"

#可视化
visualdl --logdir vdl_dir/garbage_eigth

# 导出模型
python tools/export_model.py -c configs/yolov3/yolov3_darknet53_270e_voc.yml --output_dir=./inference_model/10_14 -o weights="D:/WebDownload/49.pdparams"

## 部署检测 摄像头
python deploy/python/infer.py --model_dir="D:\19693\Desktop\DeepLearning\PaddleYOLO\inference_model\10_14\yolov3_darknet53_270e_voc" --camera_id=1 --device=GPU

# 部署推理
python deploy/python/infer.py --model_dir="D:/19693/Desktop/DeepLearning/PaddleYOLO/inference_model/82.7_yolov3_darknet53_270e_voc" --image_dir="D:/19693/Desktop/grabage_data/4_cls/valid" --device=GPU --output_dir=output/valid

训练错误

CUDA[700]

目前怀疑是版本装错了

1
2
OSError: (External) CUDA error(700), an illegal memory access was encountered.
[Hint: Please search for the error code(700) on website (https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__TYPES.html#group__CUDART__TYPES_1g3f51e3575c2178246db0a94a430e0038) to get Nvidia's official solution and advice about CUDA Error.] (at ../paddle/phi/backends/gpu/cuda/cuda_info.cc:259)

opencv 错误

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[09/15 08:14:44] reader WARNING: fail to map batch transform [BatchRandomResize_cf5b10] with error: OpenCV(4.5.5) :-1: error: (-5:Bad argument) in function 'resize'
> Overload resolution failed:
> - Conversion error: src
> - Expected Ptr<cv::UMat> for argument 'src'
and stack:
Traceback (most recent call last):
File "D:\19693\Desktop\DeepLearning\PaddleYOLO\ppdet\data\reader.py", line 78, in __call__
data = f(data)
File "D:\19693\Desktop\DeepLearning\PaddleYOLO\ppdet\data\transform\batch_operators.py", line 155, in __call__
return resizer(samples, context=context)
File "D:\19693\Desktop\DeepLearning\PaddleYOLO\ppdet\data\transform\operators.py", line 102, in __call__
sample[i] = self.apply(sample[i], context)
File "D:\19693\Desktop\DeepLearning\PaddleYOLO\ppdet\data\transform\operators.py", line 1298, in apply
im = self.apply_image(sample['image'], [im_scale_x, im_scale_y])
File "D:\19693\Desktop\DeepLearning\PaddleYOLO\ppdet\data\transform\operators.py", line 1195, in apply_image
return cv2.resize(
cv2.error: OpenCV(4.5.5) :-1: error: (-5:Bad argument) in function 'resize'
> Overload resolution failed:
> - Conversion error: src
> - Expected Ptr<cv::UMat> for argument 'src'

paddle
https://blog.xsaistudio.cn/Deep-learning/2023/10/16/deep learning/paddle/
作者
YWM
发布于
2023年10月16日
许可协议